Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 1 | Structuring and Testing Data#1073
Open
Richiealx wants to merge 17 commits intoCodeYourFuture:mainfrom
Open
Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 1 | Structuring and Testing Data#1073Richiealx wants to merge 17 commits intoCodeYourFuture:mainfrom
Richiealx wants to merge 17 commits intoCodeYourFuture:mainfrom
Conversation
cjyuan
reviewed
Feb 26, 2026
Contributor
cjyuan
left a comment
There was a problem hiding this comment.
Very clear explanation and answers! I just have two follow-up questions.
Comment on lines
+10
to
+11
| // Line 3 takes the current value of count (0), adds 1 to it, | ||
| // and assigns the result (1) back to the count variable using =. No newline at end of file |
Contributor
There was a problem hiding this comment.
Operation like count = count + 1 is very common in programming, and there is a programming term describing such operation.
Can you find out what one-word programming term describes the operation on line 3?
Comment on lines
+141
to
+145
| 5) `const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0");` | ||
| - First, `substring(length - 2)` takes the last 2 digits. | ||
| - Then `padEnd(2, "0")` ensures it’s at least 2 characters (adds zeros on the right if needed). | ||
| - Purpose: get exactly two pence digits. | ||
| - For `"399"`, last two digits are `"99"` → stays `"99"`. |
Contributor
There was a problem hiding this comment.
Could we expect this program to work as intended for any valid penceString if we deleted .padEnd(2, "0") from the code?
In other words, do we really need .padEnd(2, "0") in this script?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Learners, PR Template
Self checklist
Changelist
Completed Sprint 1 coursework:
Thanks for the feedback @cjyuan!
Answers to follow-up questions
Programming term for
count = count + 1The one-word programming term is increment.
The statement increases the value stored in the variable by 1 and assigns the updated value back to the same variable.
This pattern is very common and can also be written using shorthand operators such as
count += 1;orcount++;.Is
.padEnd(2, "0")necessary?Yes,
.padEnd(2, "0")is needed to handle cases where the pence value has fewer than two digits.For example:
penceString = "5p", removing"p"gives"5"substring(length - 2)would return"5"(only one digit)Without
.padEnd(2, "0"), the output would be£0.5.With
.padEnd(2, "0"), it becomes£0.50.So
.padEndensures the pence part always contains exactly two digits, which is required for correct currency formatting.